<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="d" uri="http://dgg.net/jsp/jstl/core" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!DOCTYPE html>
<html>
<head>
    <title>接单明细</title>
    <jsp:include page="/WEB-INF/jsp/header.jsp"/>
    <link rel="stylesheet" href="${rootUrl}/static/css/time-status-color.css?v=${version}">
    <link rel="stylesheet" type="text/css" href="${basePath}/static/css/production.css?v1"/>
    <style>
        table.crm-table.cell-border tbody td{
            white-space: nowrap;
        }
    </style>
</head>
<body>
<div class="body-main">
    <div>
        <div class="titleSearch">
            <form id="titleSearch">
                <div class="layui-inline">
                    <label>接单日期：</label>
                    <div class="layui-inline">
                        <input type="text" name="receiveTimeStart" placeholder="开始时间" class="Wdate input-style"
                               id="d4311"
                               onFocus="var d4312=$dp.$('d4312'); WdatePicker({onpicked:function(){d4312.focus();}, maxDate:'#F{ $dp.$D(\'d4312\')}', dateFmt:'yyyy-MM-dd'})">
                    </div>
                    <span>~</span>
                    <div class="layui-inline">
                        <input type="text" name="receiveTimeEnd" placeholder="结束时间" class="Wdate input-style"
                               id="d4312"
                               onFocus="WdatePicker({minDate:'#F{$dp.$D(\'d4311\')}', dateFmt:'yyyy-MM-dd'})">
                    </div>
                </div>
                <d:hasUrlAuth authCode="ZZSC_ZS_SYB">
                    <div class="layui-inline">
                        <label>所属事业部：</label>
                        <div class="layui-input-inline">
                            <select name="signOrgId" id="signOrgId" class="input-style" autocomplete="off" onchange="changUser('#flowUserId')">
                                <option value="">全部</option>
                            </select>
                        </div>
                    </div>
                </d:hasUrlAuth>
                <div class="layui-inline" style="margin-left: 10px;">
                    <label>流程人员：</label>
                    <div class="layui-input-inline select2-inline">
                        <select class="select-style" id="flowUserId" name="flowUserId" divisionUser-select-law>
                            <option value>请选择</option>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label>业务类型：</label>
                    <div class="layui-input-inline" style="width:180px;">
                        <div id="business_typeCode">
                            <input type="hidden" name="typeCodeId" class="plug-in-msg"/>
                            <input type="hidden" name="typeCode" id="typeCode" class="plug-in-code"/>
                            <input type="text" readonly placeholder="请选择业态" class="chose-plugIn layui-input"
                                   name="businessName">
                            <div class="bus-picker">
                                <div class="bus-picker-tab">
                                    <a href="javascript:void(0);" class="active">请选择业态</a>
                                </div>
                                <div class="bus-picker-content"></div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-inline" style="margin-left: 10px;">
                    <label>订单产品：</label>
                    <div class="layui-input-inline select2-inline">
                        <select class="select-style" id="productName" name="productName" divisionUser-select-law>
                            <option value>请选择</option>
                            <c:forEach var="p" items="${product}">
                                <option value="${p.productName}">
                                        ${p.productName}</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>
                <div class="layui-inline" style="margin-left: 10px;">
                    <label>完成节点：</label>
                    <div class="layui-input-inline select2-inline">
                        <select class="select-style" id="finishNodeId" name="finishNodeId" divisionUser-select-law>
                            <option value>请选择</option>
                            <c:forEach var="node" items="${finishNode}">
                                <option value="${node.nodeName}">
                                        ${node.nodeName}</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>
                <div class="layui-inline" style="margin-left: 10px;">
                    <label>项目类型：</label>
                    <div class="layui-input-inline select2-inline">
                        <select class="select-style" id="flowType" name="flowType" divisionUser-select-law>
                            <option value>请选择</option>
                            <c:forEach var="flow" items="${flowType}">
                                <option value="${flow.code}">
                                        ${flow.name}</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>
                <div class="layui-inline" style="margin-left: 10px;">
                    <label>超期状态：</label>
                    <div class="layui-input-inline select2-inline">
                        <select class="select-style" id="overStatus" name="overStatus" divisionUser-select-law>
                            <option value>请选择</option>
                            <option value="1">节点超期</option>
                            <option value="2">节点未超期</option>
                            <option value="3">订单超期</option>
                            <option value="4">订单未超期</option>
                            <option value="5">合同超期</option>
                            <option value="6">合同未超期</option>
                        </select>
                    </div>
                </div>
                <div class="layui-inline" style="margin-left: 10px;">
                    <label>订单状态：</label>
                    <div class="layui-input-inline select2-inline">
                        <select class="select-style" id="orderStatus" name="orderStatus" divisionUser-select-law>
                            <option value>请选择</option>
                            <c:forEach var="status" items="${orderStatus}">
                                <option value="${status.code}">
                                        ${status.name}</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>
                <div class="layui-inline" style="margin-left: 10px;">
                    <label>交件/公示/通告：</label>
                    <div class="layui-input-inline select2-inline">
                        <select class="select-style" id="nodeStatus" name="nodeStatus" divisionUser-select-law>
                            <option value>请选择</option>
                            <option value="1">交件</option>
                            <option value="2">公示</option>
                            <option value="3">公示通过</option>
                            <option value="4">公示不通过</option>
                            <option value="5">通告</option>
                            <option value="6">通告通过</option>
                            <option value="7">通告不通过</option>
                        </select>
                    </div>
                </div>
            <div class="layui-inline" style="margin-left: 12px;">
                <label>关键字：</label>
                <div class="layui-input-inline">
                    <input type="text" class="input-style" style="width: 300px;" placeholder="客户名称/订单编号/生产订单编号/企业名称/合同编号"
                           maxlength="50"
                           id="searchKey"
                           name="searchKey">
                </div>
            </div>

            <div class="layui-inline">
                <button class="layui-btn layui-btn-mini layui-btn-normal" type="button" onclick="dataTableReload()">搜索</button>
                <button class="layui-btn layui-btn-mini layui-btn-primary" type="button" onclick="cleanSearch()">清空</button>
                <d:hasUrlAuth authCode="ZZSC_INPROCESS_EXPORT">
                <button class="layui-btn layui-btn-mini layui-btn-green" type="button" onclick="exportIprocessData()">导出</button>
                </d:hasUrlAuth>
            </div>
            </form>
        </div>
            <div class="dataTables_wrapper no-footer">
                <!--表格 end-->
                <table class="cell-border crm-table columnsHidden" id="inProcessTable">
                    <thead>
                    <tr>
                        <th width="60">序号</th>
                        <th width="100">生产订单号</th>
                        <th width="100">销售订单号</th>
                        <th width="100">接单时间</th>
                        <th width="130">客户名称</th>
                        <th width="100">企业名称</th>
                        <th width="100">业务类型</th>
                        <th width="80">订单产品</th>
                        <th width="100">产品属性</th>
                        <th width="130">合同到期时间</th>
                        <th width="100">合同编号</th>
                        <th width="80">合同金额</th>
                        <th width="100">订单状态</th>
                        <th width="80">当前完成节点</th>
                        <th width="80">下一个节点</th>
                        <th width="100">项目类型</th>
                        <th width="100">当前流程人员</th>
                        <th width="100">生产负责人</th>
                        <th width="100">签单商务</th>
                        <th width="80">当前节点超期时长</th>
                        <th width="80">订单超期时长</th>
                        <th width="80">合同超期时长</th>
                        <th width="80">节点超期记录</th>
                        <th width="80">交件次数</th>
                        <th width="80">公示不通过次数</th>
                        <th width="80">通告不通过次数</th>
                    </tr>
                    </thead>
                </table>
            </div>
        </div>
    </div>
    <jsp:include page="/WEB-INF/jsp/footer.jsp"/>
    <script src="${rootUrl}/static/js/zzsc/common/functionalTool.js?v=${orderBusinessNoversion}"></script>
    <script type="text/javascript" src="${rootUrl}/static/js/zzsc/production/sc_common.js?v=${version}"></script>
    <script src="${rootUrl}/static/js/zzsc/common/sc_chooseUser.js?v=${version}" type="text/javascript" charset="utf-8"></script>
    <script src="${rootUrl}/static/js/zzsc/credential/credentailCommon/credentailCommon.js?v=${version}" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript" charset="utf-8">
        Plug.plug_ins("post", "${basePath}/zzsc/common/tree_book_list.do?code=BUS_YT_ZZ&&type=2&&level=3", "#business_typeCode", '选择业态', '', true, 'BUS_YT_ZZ', '', '');
        var table;
        $(document).ready(function () {
            //初始化dataTable列表
            table = $('#inProcessTable').dataTableExtend({
                "ajax": {
                    "url": "${basePath}/zzsc/statistics/detail_list.do",
                    "type": "post"
                },
                "fnServerParams": function (aoData) {
                    aoData = $.extend(aoData, $.extend({type: $('#type').val()}, $('.titleSearch').serializeJson()));
                    return aoData;
                },
                "scrollX": true,//是否开启横项滚动
                "fixedColumns": {//锁定列，只有开启scrollX时才生效
                    "leftColumns": 4,//左侧锁定2列
                    "rightColumns": 1//右侧锁定1列
                },
                "aoColumns": [
                    {
                        "orderable": false,
                        "render": function (data, type, full, meta) {
                            return meta.row + 1;
                        }
                    } ,{//生产订单编号
                        "orderable": false,
                        "data": "scProductOrderNo",
                    },{//销售订单编号
                        "orderable": false,
                        "data": "orderNo",
                    },{//接单时间
                        "orderable": false,
                        "data": "receiveTime",
                    }, {
                        //客户名称
                        "orderable": false,
                        "data": "customerName",
                        "render": function (d, type, r) {
                            return emptyStringConvert(d) + '<p>' + emptyStringConvert(r.customerPhone) + '</p>';
                        }
                    }
                    ,{//企业名称
                        "orderable": false,
                        "data": "companyName",
                        "render": function (d, type, r) {
                            if(d) {
                                var htm = '<p class="line2 remarkAlertClass" style="min-width: 100px" title="' + d + '">' + d + '</p>';
                                return htm;
                            }else{
                                return '';
                            }
                        }
                    }, {//业务类型
                        "orderable": false,
                        "data": "businessProductName"
                    }, {//订单产品d
                        "orderable": false,
                        "data": "productName"
                    },{//产品属性
                        "orderable": false,
                        "data": "productAttr",
                    },{//合同周期
                        "orderable": false,
                        "data": "contractEndDate",
                        "render": function (data, type, full,meta) {
                            return data ? data : '';
                        }
                    }, {//合同编号
                        "orderable": false,
                        "data": "contractNo"
                    },{//合同金额
                        "orderable": false,
                        "data": "money"
                    }, {//订单状态
                        "orderable": false,
                        "data": "status"
                    },{//当前完成节点
                        "orderable": false,
                        "data": "latestEndNodeName"
                    },
                    {//下一个节点
                        "orderable": false,
                        "data": "currentNodeName"
                    },{//项目类型
                        "orderable": false,
                        "data": "flowType"
                    }, { //当前流程人员
                        "orderable": false,
                        "data": "flowUserName",
                    }, { //生产负责人
                        "orderable": false,
                        "data": "productUserName",
                        "render": function (d, type, r) {
                            return d ? d : '';
                        }
                    },
                    { //签单商务
                        "orderable": false,
                        "data": "signUserName"
                    }, {//当前节点超时长
                        "data": "nodeStr",
                        "orderable": false,
                    }
                    , {//订单超时长
                        "data": "orderStr",
                        "orderable": false,
                    }
                    , {//合同超时长
                        "data": "contractStr",
                        "orderable": false,
                    }
                    , {//节点超期记录
                        "data": "overStr",
                        "orderable": false,
                    }
                    , {//交件次数
                        "data": "deliveryNum",
                        "orderable": false,
                    }
                    , {//公示不通过次数
                        "data": "publicityNotPassNum",
                        "orderable": false,
                    }
                    , {//通告不通过次数
                        "data": "noticeNotPassNum",
                        "orderable": false,
                    }]
            });
            $('.title-tab').on('click', 'a', null, function () {
                var $this = $(this);
                var status = $this.attr('data-status');
                var href = window.location.href;
                if (href.indexOf('status=') > -1) {
                    href = href.substring(0, href.indexOf('status=') - 1);
                }
                window.location.href = href + (href.indexOf('?') > -1 ? '&' : '?') + 'status=' + status;
            });
            //初始化签单商务
            // chooseUserPlug.init($('#flowUserId'), {
            //     width: '150px',
            //     select: false,
            //     url: sysInfo.basePath + '/zzsc/common/find_user_choose.do',
            //     // multiple:true,// 单选false或不写该参数，多选true
            //     otherParam: {
            //         /**
            //          * type: 用户信息选择类型（必填）
            //          *       all:全部用户，division：当前登录人所在事业部，department:当前登录人所在部门及以下，role: 查询指定角色用户，
            //          * roleCode : 角色Code，（type为role时，必填）
            //          * locked: 用户状态，（选填，默认全部状态）
            //          *      0、正常；1、锁定；2、离职
            //          */
            //         type: 'all',
            //         length: 50,
            //         start:0
            //     }
            // });
            signOrgTreeBookCode('[name="signOrgId"]')

            //提成人员
            // chooseUserPlug.init($('#flowUserId'),{
            //     url:sysInfo.basePath+'/zzsc/common/find_user_choose.do',
            //     otherParam:{
            //         /**
            //          * type: 用户信息选择类型（必填）
            //          *       all:全部用户，division：当前登录人所在事业部，department:当前登录人所在部门及以下，role: 查询指定角色用户，
            //          * roleCode : 角色Code，（type为role时，必填）
            //          * locked: 用户状态，（选填，默认全部状态）
            //          *      0、正常；1、锁定；2、离职
            //          */
            //         type:'division',
            //         locked:0
            //     }
            // });
            changUser1($('#flowUserId'))
            $("#finishNodeId").select2({
                placeholder: "请选择",
                allowClear: true,
                width: "150px",
                language: "zh-CN"
            });
            $("#productName").select2({
                placeholder: "请选择",
                allowClear: true,
                width: "150px",
                language: "zh-CN"
            });
            $("#orderStatus").select2({
                placeholder: "请选择",
                allowClear: true,
                width: "150px",
                language: "zh-CN"
            });
        });

        function signOrgTreeBookCode(obj) {
            $(obj).find("option").remove();
            $(obj).append("<option value=''>请选择</option>");
            $.post(sysInfo.basePath + '/zzsc/common/find_all_syb.do', function (result) {
                if (result.code == 0) {
                    $.each(result.data, function (i, item) {
                        $(obj).append("<option value='" + item.id + "'>" + item.name + "</option>");
                    });
                } else {
                    DGG.Errors("系统错误，请联系管理员");
                }
            });
            $(obj).select2({
                placeholder: "请选择",
                allowClear: true,
                width: "150px",
                language: "zh-CN"
            });
        }
        function changUser(obj) {
            console.log(obj);
            $(obj).find("option").remove();
            $(obj).append("<option value=''>请选择</option>");
            $.post(sysInfo.basePath + '/zzsc/common/find_user_choose.do',{organId:$("#signOrgId").val(), locked:0}, function (result) {
                if (result.code == 0) {
                    console.log(result.data);
                    $.each(result.data, function (i, item) {
                        $(obj).append("<option value='" + item.id + "'>" + item.realName+item.loginName + "</option>");
                    });
                } else {
                    DGG.Errors("系统错误，请联系管理员");
                }
            });
            $(obj).select2({
                placeholder: "请选择",
                allowClear: true,
                width: "200px",
                language: "zh-CN"
            });
        }


        //导出办理中数据
        function exportIprocessData() {
            var paras = $('.titleSearch').serialize2object();
            if (Object.keys(paras).length == 0) {
                DGG.Warning('请加入搜索条件后导出！');
                return;
            }
            $.extend(paras, {type: $(".title-tab").find("a.active").attr("data-status")});
            exportDataAbandoned('/zzsc/statistics/export_order_detail.do', paras);
        }


        // 获取搜索数据
        function getSearchData2() {
            // debugger;
            return $.extend({type: $('#type').val()}, $('.titleSearch').serializeJson());
        }
        function emptyStringConvert(str) {
            if (null == str || '' == str) {
                return '';
            } else {
                return str;
            }
        }
        function changUser1(obj) {
            $(obj).find("option").remove();
            $(obj).append("<option value=''>请选择</option>");
            $.post(sysInfo.basePath + '/zzsc/common/find_user_choose.do',{ type:'division', locked:0}, function (result) {
                if (result.code == 0) {
                    console.log(result.data);
                    $.each(result.data, function (i, item) {
                        $(obj).append("<option value='" + item.id + "'>" + item.realName+item.loginName + "</option>");
                    });
                } else {
                    DGG.Errors("系统错误，请联系管理员");
                }
            });
            $(obj).select2({
                placeholder: "请选择",
                allowClear: true,
                width: "200px",
                language: "zh-CN"
            });
        }


    </script>
</div>
</body>
</html>
